# encoding: utf-8

class User < ActiveRecord::Base
  # Include default devise modules. Others available are:
  # :token_authenticatable, :confirmable, :lockable and :timeoutable
  devise  :database_authenticatable,
          :registerable,
          :recoverable,
          :rememberable,
          :trackable,
          :validatable,
          :timeoutable, :timeout_in => 15.minutes

  has_many  :bugs_created,
            :class_name => "Bug",
            :foreign_key => "author_id"

  has_many  :bugs_in_progress,
            :class_name => "Bug",
            :foreign_key => "processor_id"
  
  has_many  :replies

  has_many  :topics

  has_many  :processors,
            :dependent  =>  :destroy

  has_many  :tasks,
            :through => :processors

  has_many  :members,
            :dependent  =>  :destroy

  has_many  :projects,
            :through => :members

  validates :alias,
            :presence => true,
            :length   =>  { :within      => 6..32, :unless => "self.alias.empty?"  }
end

# == Schema Information
#
# Table name: users
#
#  id                   :integer         not null, primary key
#  alias                :string(255)
#  created_at           :datetime
#  updated_at           :datetime
#  email                :string(255)     default(""), not null
#  encrypted_password   :string(128)     default(""), not null
#  password_salt        :string(255)     default(""), not null
#  reset_password_token :string(255)
#  remember_token       :string(255)
#  remember_created_at  :datetime
#  sign_in_count        :integer         default(0)
#  current_sign_in_at   :datetime
#  last_sign_in_at      :datetime
#  current_sign_in_ip   :string(255)
#  last_sign_in_ip      :string(255)
#

